//
//  UITableVIew+Extension.swift
//  CMDB
//
//  Created by 曹桂祥 on 17/4/9.
//  Copyright © 2017年 CMDB. All rights reserved.
//

import UIKit

extension UITableView {
    
    func dequeCellAndLoadContentFromAdapter(adapter : CellAdapter, indexPath : NSIndexPath,tableView : CMDBBaseTableView? = nil,controller : UIViewController? = nil,cellReuseIdentifier : String) -> CustomBaseCell{
        
        let cell         = self.dequeueReusableCellWithIdentifier(cellReuseIdentifier) as! CustomBaseCell
        
        cell.indexPath   = indexPath
        cell.dataAdapter = adapter
        cell.cellData    = adapter.data
        cell.tableView   = tableView
        cell.controller  = controller
        cell.mDelegate   = tableView
        cell.loadContent()
        
        return cell
    }
    
    func selectedEventWithIndexPath(indexPath : NSIndexPath) {
        
        let cell = self.cellForRowAtIndexPath(indexPath) as! CustomBaseCell
        
        cell.selectedEvent()
    }
    
}


//extension UITableView : CustomBaseCellDelegate {
//    
//    func customCell(cell: CustomBaseCell?, event: AnyObject?) {
//        
//    }
//    
//}